
@echo off

if "%1"=="" (
    echo need an ip to search
) else (
    del /q apnic.txt 1> nul 2> nul
    wget -O apnic.txt "http://wq.apnic.net/apnic-bin/whois.pl?searchtext=%1" 1> nul 2> nul
    for /f %%x in ('grepw apnic.txt /- "netname:      " ^| replacew /- /- "netname:      " "" ^| select -r 0 /- /-') do set netname=%%x
    for /f %%x in ('grepw apnic.txt /- "country:      " ^| replacew /- /- "country:      " "" ^| select -r 0 /- /-') do set country=%%x
    echo %netname%-%country%
    del /q apnic.txt 1> nul 2> nul
)

